<template>
  <div class="about">
    账号:<input v-model="user" type="text">
    密码:<input v-model="pwd" type="text">
    <button @click="loginCom">登录</button>
  </div>
</template>
<script>
  import {mapActions} from 'vuex'
  export default {
    name:'Login',
    data(){
      return{
        user:'',
        pwd:''
      }
    },
    methods:{
      ...mapActions(['login','loginOut']),//将action的login和loginout导出到methods里面
      loginCom(){
        // 发起登录
        let user = {
          user:this.user,
          pwd:this.pwd
        }
        this.login(user).then(res=>{
          if(res===200) this.$router.push('/home/tablea')
        })
        // this.$router.push('/home')
      }
    }
  }
</script>
